package com.mxq.eclipse.mqtt.demo.controller;


import com.mxq.eclipse.mqtt.demo.publish.MqttPublishDto;
import com.mxq.eclipse.mqtt.demo.publish.service.MqttPublishService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * MQTT测试控制层
 *
 * @author xiaoqiang
 * @date 2020-05-09 17:41
 */
@Slf4j
@RestController
@RequestMapping(value = "/v1/mq")
public class MqttController {

    @Autowired
    private MqttPublishService mqttPublishService;

    /**
     * 原始发布主题
     *
     * @param mqttPublishDto
     * @return
     */
    @PostMapping("/publishOrigin")
    public Boolean publishOrigin(@RequestBody @Valid MqttPublishDto mqttPublishDto){
        log.info("进入到【MqttController】的[publishOrigin]方法，入参：{}", mqttPublishDto);
        return mqttPublishService.publishOrigin(mqttPublishDto);
    }
}
